﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id')
	BEGIN
		DROP Procedure usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id
	END
GO

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

/******************************************************************************
**	Name : usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id
**	Desc : 첨부파일목록 조회
**	Test Exec Query : Exec usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id 113, 'Ref1012m'
**	Called by : All
**	Program ID : All
**	Auth : 송시명
**	Date : 2013-06-13
*******************************************************************************
**	Change History
*******************************************************************************
**	Date:		Author:		Description:
**	--------	--------	---------------------------------------
**						
*******************************************************************************/
CREATE PROC [dbo].[usp_UPDMS_COM_FILE_Get_File_Info_By_Activity_Id]
@activity_id int,
@activity_cd nvarchar(10)
AS
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET NOCOUNT ON

SELECT File_Id,
       Activity_Id,
       Activity_Cd,
       File_Dir,
       File_Nm,
	   File_Size,
       File_Ext,
       File_W_Size,
       File_H_Size,
	   '<a href="javascript:void(0);" onclick="doDownload(''' + rtrim(ltrim(Hash_Key)) + ''')">'
	   + File_Nm + ' (' + dbo.ufn_UPDMS_Convert_Money(convert(varchar, File_Size)) + 'KB)'
	   + '</a>' AS Download_Link,
	   '<a href="javascript:void(0);" onclick="doDownload(''' + rtrim(ltrim(Hash_Key)) + ''')">'
	   + File_Nm + '</a>' AS Download_Link_File_Nm,
       Create_User,
       Create_Dt
  FROM UPDMS_COM_FILE WITH(NOLOCK)
 WHERE Activity_Id = @activity_id
   AND Activity_Cd = @activity_cd

GO